<?
class baseSql{
	protected $last_req;
	protected $erreurs;
	protected $connexion;
	protected $req_string;
	function __construct(){
		$this->erreurs=0;
		//$connexion=@mysql_connect('localhost','mymyoux','zt15ed7g') or $this->onError();
		$connexion=@mysql_connect('cl1-sql2','phoenixxxx5','am237ldzt15ed7g') or $this->onError();
		if($this->erreurs==0){
			//@mysql_select_db('appel') or $this->onError();
			@mysql_select_db('phoenixxxx5') or $this->onError();
		}
	}
	protected function req($requete){
		$this->req_string=$requete;
		$this->last_req = mysql_query($requete);
	}
	protected function req2array(){
		return mysql_fetch_array($this->last_req);
	}
	protected function req2row(){
		return mysql_fetch_row($this->last_req);	
	}
	public function getReq(){
		return $this->req_string;
	}
	public function req2void($requete=""){
		if($this->erreurs==0){
			if(strlen($requete)>0){
				$this->req($requete);
			}
		}
		return	$requete;
	}
	public function req2num($requete=""){
		if($this->erreurs==0){
			if(strlen($requete)>0){
				$this->req($requete);
			}
		}
		return $this->getRows();
	}
	public function req2tab($requete=""){
		if($this->erreurs==0){
			if(strlen($requete)>0){
				$this->req($requete);
			}
			if(isset($this->last_req)){
				for($i=0;$i<$this->getRows();$i++){
					$my_tab[$i]=$this->req2array();
				}
				return $my_tab;
			}
		}
		return "false";
	}
	public function req2rows($requete=""){
		if($this->erreurs==0){
			if(strlen($requete)>0){
				$this->req($requete);
			}
			if(isset($this->last_req)){
				for($i=0;$i<$this->getRows();$i++){
					$my_tab[$i]=$this->req2row();
				}
				return $my_tab;
			}
		}
		return "false";
	}
	protected function getRows(){
		return mysql_num_rows($this->last_req);
	}
	function __destruct(){
		@mysql_close($connexion);
	}
	protected function onError(){
		include_once("error.php");
		$erreur=Error::getInstance();
		$erreur->append("[Error:base]");
		$this->erreurs=1;
	}
}
?>
